<%

  require 'net/http'
  require 'rexml/document'
  
  url = 'http://192.168.23.159:8080/CasaApuestasEEL/rest'    
  xml_data = Net::HTTP.get_response(URI.parse(url)).body  
  doc = REXML::Document.new(xml_data)

 %>


<table width="600" border="6">

<%
@counter=1
doc.elements.each('list/event') do |ele| 


%>
<% for eventparticipant in @dataevent 
    for participant in Participant.find_all_by_id(eventparticipant.participant_idf)  %>  
<%  if (ele.elements["equipo1"].text == participant.acronimo || ele.elements["equipo2"].text == participant.acronimo) && (ele.elements["fecha"].text == @event.eventstart.strftime("%Y-%m-%d")) && (ele.elements["hora"].text == @event.eventstart.strftime("%H:%M")) && (@counter==1) %>
  <tr align="center" height = "45">
  	<td width="45" ><%= image_tag("/images/logos/favicon.bmp", :size => "45x45", :align => "middle"  ) %></td>
    <td colspan="5"><h1><%= ele.elements["nombre"].text %></h1></td>
  </tr>
    
  <tr align="center">
    <td>&nbsp;</td>   
    <td colspan="5"><%= ele.elements["fecha"].text %>-<%= ele.elements["hora"].text %></td>
 </tr>
</table>
<table width="600" border="6">
 
   <tr align="center">
   	<td>Logo</td>
	<td>Equipo</td>
	<td>Proporcion</td>       
  </tr>
  
<%
@team1=Participant.find_by_acronimo(ele.elements["equipo1"].text)
@team2=Participant.find_by_acronimo(ele.elements["equipo2"].text)

%>
<tr align ="center">
<td width="65" align="center">
	<% if(@team1.photo_file_name.blank?)&(participant.image.blank?) %>
		<%= image_tag("/images/default.jpg", :size => "60x60", :align => "middle"  ) %>
	<% end %>
	<% if(@team1.photo_file_name.blank?)%>
		<%= image_tag participant.image, :size => "60x60", :align => "middle"  %>
	<% end %>
	<% if(@team1.image.blank?)%>
		<%= image_tag participant.photo.url, :size => "60x60", :align => "middle"  %>
	<% end %>	
</td>
<td><%=h @team1.name %></td>
<td><%=h ele.elements["proporcion1"].text %></td>
</tr>
<tr align ="center">
<td width="65">
	<% if(@team2.photo_file_name.blank?)&(participant.image.blank?) %>
		<%= image_tag("/images/default.jpg", :size => "60x60", :align => "middle"  ) %>
	<% end %>
	<% if(@team2.photo_file_name.blank?)%>
		<%= image_tag @team2.image, :size => "60x60", :align => "middle"  %>
	<% end %>
	<% if(@team2.image.blank?)%>
		<%= image_tag @team2.photo.url, :size => "60x60", :align => "middle"  %>
	<% end %>	
</td>
<td><%=h @team2.name %></td>
<td><%=h ele.elements["proporcion2"].text %></td>
</tr>
<%
  end
  @counter=2
 end
end
@counter=1
end

%>
</table>
<table>
<tr>
    <td colspan="5" align="center"><%= link_to "Regresar", "/events/"+@event.id.to_s  %></td>
</tr>
</table>